From: Alex Crichton Date: Fri, 2 Jun 2017 14:00:17 +0000 (-0700) Subject: Try to not allocate when decoding registry json X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~9^2~8^2~15 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=337359afdf0a561eaa5826a4e09df5aa8b78a99f;p=cargo.git Try to not allocate when decoding registry json There's a few keys we don't need owned versions of, so try using Serde's zero-copy deserialization where we can. --- diff --git a/src/cargo/sources/registry/mod.rs b/src/cargo/sources/registry/mod.rs index 5319c4bfe..139d8a607 100644 --- a/src/cargo/sources/registry/mod.rs +++ b/src/cargo/sources/registry/mod.rs @@ -158,6 +158,7 @@ //! ... //! ``` +use std::borrow::Cow; use std::collections::HashMap; use std::fs::File; use std::path::{PathBuf, Path}; @@ -198,24 +199,24 @@ pub struct RegistryConfig { } #[derive(Deserialize)] -struct RegistryPackage { +struct RegistryPackage<'a> { name: String, vers: String, - deps: Vec, + deps: Vec>, features: HashMap>, cksum: String, yanked: Option, } #[derive(Deserialize)] -struct RegistryDependency { - name: String, - req: String, +struct RegistryDependency<'a> { + name: Cow<'a, str>, + req: Cow<'a, str>, features: Vec, optional: bool, default_features: bool, - target: Option, - kind: Option, + target: Option>, + kind: Option>, } pub trait RegistryData {